from geventwebsocket.handler import WebSocketHandler
from geventwebsocket.server import WSGIServer
from correction_service import app
import logging
import os
from setting import log_path

app.debug = True
handler = logging.FileHandler(os.path.join(log_path,'correction_service.log'), encoding='UTF-8')
handler.setLevel(logging.DEBUG)  # 设置日志记录最低级别为DEBUG，低于DEBUG级别的日志记录会被忽略，不设置setLevel()则默认为NOTSET级别。
logging_format = logging.Formatter(
    '%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s')
handler.setFormatter(logging_format)
app.logger.addHandler(handler)

if __name__ == '__main__':
    http_server = WSGIServer(('0.0.0.0', 8080), application=app, handler_class=WebSocketHandler)
    http_server.serve_forever()